########################################################################
# gmould.form.sh - GMOULD Widget formlibrary
# Copyright (C) 2013 Mohamad Afifi Omar <afifio@gmail.com>
#
# These comments cannot be remove or edited and should remain intact
# because this file comments is an extension to the GPL3 license.
# This software file is covered by GPL version 3 license.
# Please see the LICENSE and gpl3.txt or gpl3.htm in doc directory
# for the license agreement, if its not exist, write to the 
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
# Modification below this line is allowed
########################################################################
# Extra credits to:
#
########################################################################
# Notes:
# Put notes to other future developer/contributor here
#
########################################################################

function gFormBool()
{
#   '"$(gFormBool varname default text)"'

: <<'COMMENTBLOCK'
COMMENTBLOCK

local usevariable=`gInitVar "$vGUID" "vUse$1" 'false'`
local bool=`gInitVar "$vGUID" "v$1" true`
if [ "$usevariable" == "true" ]
then
	local sensitive="true"
else
	local sensitive="false"
fi
ln -sf /usr/share/icons/gmould-bool-$bool.svg $PROGTMP/v$1.svg
echo '
<hbox>
    <checkbox space-fill="true" space-expand="true">
		<label>'$2'</label>
		<default>'$usevariable'</default>
		<variable>vUse'$1'</variable>
		<action>if true enable:v'$1'</action>
		<action>if false disable:v'$1'</action>
    </checkbox>
	<togglebutton>
		<default>'$bool'</default>
		<sensitive>'$sensitive'</sensitive>
		<variable>v'$1'</variable>
		<input file>'"$PROGTMP"'/v'$1'.svg</input>
		<action>ln -sf /usr/share/icons/gmould-bool-$v'$1'.svg '"$PROGTMP"'/v'$1'.svg</action>
		<action>refresh:v'$1'</action>
	</togglebutton>
</hbox>'
};export -f gFormBool
function gFormFile()
{
	#	'"$(gFormEntry varname text)"'
local usevariable=`gInitVar "$vGUID" "vUse$1" 'false'`
local value=`gInitVar "$vGUID" "v$1" "Select a file"`
if [ "$usevariable" == "true" ]
then
	local sensitive="true"
else
	local sensitive="false"
fi
if [ ! -e $PROGTMP/v$1 ]
then
	echo " " > $PROGTMP/v$1
fi
echo '
<hbox>
	<checkbox space-fill="true" space-expand="true">
		<label>'$2'</label>
		<default>'$usevariable'</default>
		<variable>vUse'$1'</variable>
		<action>refresh:v'$1'</action>
		<action>if true enable:v'$1'</action>
		<action>if false disable:v'$1'</action>
		<action>if true enable:vSelect'$1'File</action>
		<action>if false disable:vSelect'$1'File</action>
		<action>if true enable:vClear'$1'Item</action>
		<action>if false disable:vClear'$1'Item</action>
		<action>if true enable:vHelp'$1'File</action>
		<action>if false disable:vHelp'$1'File</action>
	</checkbox>
	<comboboxentry space-fill="true" space-expand="true" fs-action="file" fs-folder="'$PROJECTDIR/src/data'" fs-filters="*.list" fs-title="Select an existing file" width-request="100">
		<sensitive>'$sensitive'</sensitive>
		<default>'$value'</default>
		<variable>v'$1'</variable>
		<input file>'$PROGTMP'/vCommonFilelist</input>
		<output file>'$PROGTMP'/vCommonFilelist</output>
		<action signal="activate">save:v'$1'</action>
	</comboboxentry>
	<button theme-icon-size="16">
		<sensitive>'$sensitive'</sensitive>
		<variable>vSelect'$1'File</variable>
		<input file icon="document-open"></input>
		<action>fileselect:v'$1'</action>
		<action>save:v'$1'</action>
	</button>
	<button theme-icon-size="16">
		<sensitive>'$sensitive'</sensitive>
		<variable export="false">vClear'$1'Item</variable>
		<input file icon="'$GMICON_ENTRY_CLEAR'"></input>
		<action>removeselected:v'$1'</action>
	</button>
	<button theme-icon-size="16">
		<sensitive>'$sensitive'</sensitive>
		<variable>vHelp'$1'File</variable>
		<input file icon="system-help"></input>
		<action>XMLRun HELP_DIALOG</action>
	</button>
</hbox>'
};export -f gFormFile
function gFormEntry()
{
	#	'"$(gFormEntry varname icon text default)"'
local usevariable=`gInitVar "$vGUID" "vUse$1" 'false'`
local value=`gInitVar "$vGUID" "v$1" $4`
if [ "$usevariable" == "true" ]
then
	local sensitive="true"
else
	local sensitive="false"
fi
echo '<hbox>
    <checkbox space-fill="true" space-expand="true">
		<label>'$3'</label>
		<default>'$usevariable'</default>
		<variable>vUse'$1'</variable>
		<action>if true enable:v'$1'</action>
		<action>if false disable:v'$1'</action>
		<action>refresh:v'$1'</action>
    </checkbox>
	<entry primary-icon-stock="'$2'"  secondary-icon-name="'$GMICON_ENTRY_CLEAR'" 
	primary-icon-activatable="false" secondary-icon-activatable="true"
	 width-request="150">
		<sensitive>'$sensitive'</sensitive>
		<action signal="primary-icon-press">clear:v'$1'</action>
		<action signal="secondary-icon-press">clear:v'$1'</action>
		<default>'$value'</default>
		<variable>v'$1'</variable>
	</entry>
</hbox>'
};export -f gFormEntry

function gFormComboSelect()
{
	#	'"$(gFormComboSelect varname selection^list^text)"'
local usevariable=`gInitVar "$vGUID" "vUse$1" 'false'`
local value=`gInitVar "$vGUID" "v$1" "None"`
if [ "$usevariable" == "true" ]
then
	local sensitive="true"
else
	local sensitive="false"
fi
	echo '<hbox>
    <checkbox space-fill="true" space-expand="true">
		<label>'$2'</label>
		<default>'$usevariable'</default>
		<variable>vUse'$1'</variable>
		<action>if true enable:v'$1'</action>
		<action>if false disable:v'$1'</action>
		<action>refresh:v'$1'</action>
    </checkbox>
    <comboboxtext fs-action="file" focus-on-click="false">
		<sensitive>'$sensitive'</sensitive>
		<variable>v'$1'</variable>
		<default>'$value'</default>'
		local ifssaved=$IFS; IFS="^";
eval itemlist=(`toArray $3`)
IFS=$ifsaved
local element_count=${#itemlist[@]}
local index=0
while [ "$index" -lt "$element_count" ]
	do    # List all the elements in the array.
		echo '<item>'${itemlist[$index]}'</item>'
		let "index = $index + 1"
	done
echo '
    </comboboxtext>
</hbox>'
};export -f gFormComboSelect

function gFormSelectColor()
{
#   '"$(gFormSelectColor varname text)"'
local usevariable=`gInitVar "$vGUID" "vUse$1" 'false'`
local value=`gInitVar "$vGUID" "v$1" "#334455|49152"`
if [ "$usevariable" == "true" ]
then
	local sensitive="true"
else
	local sensitive="false"
fi
echo '
<hbox>
    <checkbox space-fill="true" space-expand="true">
		<label>'$2'</label>
		<default>'$usevariable'</default>
		<variable>vUse'$1'</variable>
		<action>if true enable:v'$1'</action>
		<action>if false disable:v'$1'</action>
    </checkbox>
    <colorbutton width-request="100" use-alpha="true" title="Choose something asthetically pleasing">
		<sensitive>'$sensitive'</sensitive>
		<variable>v'$1'</variable>
		<default>'$value'</default>
	</colorbutton>
</hbox>'
};export -f gFormSelectColor

function gFormPosition()
{
#   '"$(gFormPosition varname text)"'
local usevariable=`gInitVar "$vGUID" "vUse$1" 'false'`
local value=`gInitVar "$vGUID" "v$1" "1"`
if [ "$value" == "0" ]
then
	local sensitive0="false"
	local sensitive1="true"
	local sensitive2="true"
	local sensitive3="true"
elif [ "$value" == "1" ]
then
	local sensitive0="true"
	local sensitive1="false"
	local sensitive2="true"
	local sensitive3="true"
elif [ "$value" == "2" ]
then
	local sensitive0="true"
	local sensitive1="true"
	local sensitive2="false"
	local sensitive3="true"
elif [ "$value" == "3" ]
then
	local sensitive0="true"
	local sensitive1="true"
	local sensitive2="true"
	local sensitive3="false"
fi
echo '
<hbox>
    <checkbox space-fill="true" space-expand="true">
		<label>'$2'</label>
		<default>'$usevariable'</default>
		<variable>vUse'$1'</variable>
		<action>if true enable:v0</action>
		<action>if true enable:v1</action>
		<action>if true enable:v2</action>
		<action>if true enable:v3</action>
		<action>if false disable:v0</action>
		<action>if false disable:v1</action>
		<action>if false disable:v2</action>
		<action>if false disable:v3</action>
    </checkbox>
	<hbox>
		<vbox>
			<hbox>
				<button><sensitive>false</sensitive><input file icon="'$GMICON_BUTTON_BLANK'"></input></button>
				<button>
					<variable export="false">v2</variable>
					<sensitive>'$sensitive2'</sensitive>
					<input file icon="'$GMICON_POSITION_TOP'"></input>
					<action>enable:v0</action>
					<action>enable:v1</action>
					<action>disable:v2</action>
					<action>enable:v3</action>
					<action>echo "export v'$1'=2" > '$PROGTMP'/v'$1'</action>
				</button>
				<button><sensitive>false</sensitive><input file icon="'$GMICON_BUTTON_BLANK'"></input></button>
			</hbox>
			<hbox>
				<button>
					<variable export="false">v0</variable>
					<sensitive>'$sensitive0'</sensitive>
					<input file icon="'$GMICON_POSITION_LEFT'"></input>
					<action>disable:v0</action>
					<action>enable:v1</action>
					<action>enable:v2</action>
					<action>enable:v3</action>
					<action>echo "export v'$1'=0" > '$PROGTMP'/v'$1'</action>
				</button>
				<button><sensitive>false</sensitive><input file icon="'$GMICON_BUTTON_BLANK'"></input></button>
				<button>
					<variable export="false">v1</variable>
					<sensitive>'$sensitive1'</sensitive>
					<input file icon="'$GMICON_POSITION_RIGHT'"></input>
					<action>enable:v0</action>
					<action>disable:v1</action>
					<action>enable:v2</action>
					<action>enable:v3</action>
					<action>echo "export v'$1'=1" > '$PROGTMP'/v'$1'</action>
				</button>
			</hbox>
			<hbox>
				<button><sensitive>false</sensitive><input file icon="'$GMICON_BUTTON_BLANK'"></input></button>
				<button>
					<variable export="false">v3</variable>
					<sensitive>'$sensitive3'</sensitive>
					<input file icon="'$GMICON_POSITION_BOTTOM'"></input>
					<action>enable:v0</action>
					<action>enable:v1</action>
					<action>enable:v2</action>
					<action>disable:v3</action>
					<action>echo "export v'$1'=3" > '$PROGTMP'/v'$1'</action>
				</button>
				<button><sensitive>false</sensitive><input file icon="'$GMICON_BUTTON_BLANK'"></input></button>
			</hbox>
		</vbox>
	</hbox>
</hbox>
'
};export -f gFormPosition

function gFormSelectInput()
{
	gFormSelectSignal "$1" "$2" input
};export -f gFormSelectInput
function gFormSelectEvent()
{
	gFormSelectSignal "$1" "$2" event
};export -f gFormSelectEvent
function gFormSelectAction()
{
	gFormSelectSignal "$1" "$2" action
};export -f gFormSelectAction
function gFormSelectSignal()
{
#   '"$(gFormSelectAction varname text)"'
local usevariable=`gInitVar "$vGUID" "vUse$1" 'false'`
local value=`gInitVar "$vGUID" "v$1" "None selected"`
echo -n $value > $PROGTMP/v$1
if [ "$usevariable" == "true" ]
then
	local sensitive="true"
else
	local sensitive="false"
fi
if [ "$3" == "event" ]
then
	local label="Select an event file"
	local labeltooltip="Select an event file to include in the XML"
	local dialog="EventManager"
	local icon=$GMICON_EVENT
elif [ "$3" == "input" ]
then
	local label="Select input directive file"
	local labeltooltip="Select directives file to include in the XML"
	local dialog="InputManager"
	local icon=$GMICON_MAST_IO
else
	local label="Select an action file"
	local labeltooltip="Select an action file to include in the XML"
	local dialog="ActionManager"
	local icon=$GMICON_ACTION
fi
echo '
<hbox>
	<checkbox space-fill="true" space-expand="true">
		<label>'$2'</label>
		<default>'$usevariable'</default>
		<variable>vUse'$1'</variable>
		<action>if true enable:v'$1'</action>
		<action>if false disable:v'$1'</action>
		<action>if true enable:v'$1'Button</action>
		<action>if false disable:v'$1'Button</action>
	</checkbox>
	<text auto-refresh="true" file-monitor="true" xalign="0">
		<variable>v'$1'</variable>
		<input file>'$PROGTMP'/v'$1'</input>
	</text>
	<button tooltip-text="'$labeltooltip'">
		<label>'$label'</label>
		<variable export="false">v'$1'Button</variable>
		<sensitive>'$sensitive'</sensitive>
		<input file icon="'$icon'"></input>
		<action>XMLRunDialog '$dialog' v'$1'</action>
	</button>
</hbox>'
};export -f gFormSelectSignal
function gFormSpinner()
{
#   '"$(gFormSpinner varname icon text default incrementstep)"'
local usevariable=`gInitVar "$vGUID" "vUse$1" 'false'`
local value=`gInitVar "$vGUID" "v$1" "$4"`
if [ "$usevariable" == "true" ]
then
	local sensitive="true"
else
	local sensitive="false"
fi
if [ ! -e $PROGTMP/v$1 ]
then
	echo " " > $PROGTMP/v$1
fi
echo '
<hbox>
    <checkbox space-fill="true" space-expand="true">
		<label>'$3'</label>
		<default>'$usevariable'</default>
		<variable>vUse'$1'</variable>
		<action>if true enable:v'$1'</action>
		<action>if false disable:v'$1'</action>
    </checkbox>
    <spinbutton  secondary-icon-name="'$2'" width-request="100" range-step="'$5'" range-max="999">
		<sensitive>'$sensitive'</sensitive>
		<variable>v'$1'</variable>
		<default>'$value'</default>
</spinbutton>
</hbox>'
};export -f gFormSpinner
function gFormSelectStockIcon()
{

#   '"$(gFormSelectStockIcon varname icon text default)"'
echo '
<vbox>
    <checkbox space-fill="true" space-expand="true">
		<label>'$3'</label>
		<default>false</default>
		<variable>vUse'$1'</variable>
		<action>if true enable:v'$1'</action>
		<action>if false disable:v'$1'</action>
    </checkbox>
			<tree rules-hint="true" exported-column="0" space-fill="false" space-expand="false">
				<label>Stock Icons</label>
				<sensitive>false</sensitive>
				<variable>v'$1'</variable>
				<input file stock-column="0">'$PROGLIB'/icon_names.txt</input>
				<height>75</height>
			</tree>'
echo '</vbox>'
};export -f gFormSelectStockIcon

function gFormSelectFont()
{

#   '"$(gFormSelectFont varname text)"'
local usevariable=`gInitVar "$vGUID" "vUse$1" 'false'`
local value=`gInitVar "$vGUID" "v$1" "Sans Bold Italic 10"`
if [ "$usevariable" == "true" ]
then
	local sensitive="true"
else
	local sensitive="false"
fi
echo '
<hbox>
	<checkbox space-fill="true" space-expand="true">
		<label>'$2'</label>
		<default>'$usevariable'</default>
		<variable>vUse'$1'</variable>
		<action>if true enable:v'$1'</action>
		<action>if false disable:v'$1'</action>
	</checkbox>
	<fontbutton use-font="true" use-size="true" tooltip-text="Select a font">
		<variable>v'$1'</variable>
		<sensitive>'$sensitive'</sensitive>
		<default>'$value'</default>
	</fontbutton>'
echo '</hbox>'
};export -f gFormSelectFont

function gFormTextEdit()
{

#   '"$(gFormSelectFont varname text contents)"'
local usevariable=`gInitVar "$vGUID" "vUse$1" 'false'`
local value=`gInitVar "$vGUID" "v$1" $3`
if [ "$usevariable" == "true" ]
then
	local sensitive="true"
else
	local sensitive="false"
fi
echo '
<vbox>
    <checkbox space-fill="true" space-expand="true">
		<label>'$2'</label>
		<default>'$usevariable'</default>
		<variable>vUse'$1'</variable>
		<action>if true enable:v'$1'</action>
		<action>if false disable:v'$1'</action>
    </checkbox>
<edit hscrollbar-policy="never" vscrollbar-policy="always">
	<default>'$value'</default>
	<variable>v'$1'</variable>
	<sensitive>'$sensitive'</sensitive>
	<height>75</height>
</edit>'
echo '</vbox>'
};export -f gFormTextEdit

function gFormSelectThemeIcon()
{

#   '"$(gFormSelectThemeIcon varname icon text default)"'
cp --force $PROGLIB/theme_actions.csv  $PROGTMP/vContext$1

echo '
<vbox>
    <checkbox space-fill="true" space-expand="true">
		<label>'$2'</label>
		<default>false</default>
		<variable>vUse'$1'</variable>
		<action>if true enable:vContext'$1'</action>
		<action>if false disable:vContext'$1'</action>
		<action>if true enable:v'$1'</action>
		<action>if false disable:v'$1'</action>
    </checkbox>
    <hbox>
			<tree rules-hint="true" exported-column="1" column-visible="true|false">
				<label>Contexts|File</label>
				<sensitive>false</sensitive>
				<variable>vContext'$1'</variable>
				<height>210</height>
				<width>50</width>
				<action signal="cursor-changed">cp --force '$PROGLIB'/$vContext'$1'  '$PROGTMP'/vContext'$1'</action>
				<action signal="cursor-changed">refresh:v'$1'</action>
				<item icon-name="system-run">Actions|theme_actions.csv</item>
				<item icon-name="application-x-executable">Applications|theme_apps.csv</item>
				<item icon-name="applications-utilities">Categories|theme_categories.csv</item>
				<item icon-name="computer">Devices|theme_devices.csv</item>
				<item icon-name="emblem-favorite">Emblems|theme_emblems.csv</item>
				<item icon-name="text-html">Mime Types|theme_mimes.csv</item>
				<item icon-name="user-desktop">Places|theme_places.csv</item>
				<item icon-name="network-transmit-receive">Status|theme_status.csv</item>
			</tree>
			<tree rules-hint="true" exported-column="0" space-fill="true" space-expand="true">
				<label>Theme Icon</label>
				<sensitive>false</sensitive>
				<variable>v'$1'</variable>
				<input file icon-column="0">'$PROGTMP'/'vContext$1'</input>
				<action signal="cursor-changed">save:v'$1'</action>
				<action signal="cursor-changed">echo $v'$1'</action>
			</tree>
    </hbox>'
echo '</vbox>'
};export -f gFormSelectThemeIcon
function gFormCheckboxList()
{

#   '"$(gFormList  varname text caret^separated^signalname )"'
echo '<frame '$2'>
<vbox spacing="0">'

	ifss=$IFS; IFS="^";
		mouldSignalList $1 $3
		
	IFS=$ifss
echo '</vbox></frame>'
};export -f gFormCheckboxList
: <<'COMMENTBLOCK'

COMMENTBLOCK

function mouldSignalList()
{
local widget=$1
shift
	for arg in "$@"
	do
	echo '<expander expanded="false">
	<vbox spacing="0">'
		mouldSignalActivate $widget $arg
	echo '	<hbox spacing="0">'
		echo '<text  space-fill="false" space-expand="false"><label> perform </label></text>'
		mouldSignalName $widget$arg
		mouldSignalParam $widget $arg
	echo '	</hbox>'
	echo '	<hbox spacing="0">'
		echo '<text  space-fill="false" space-expand="false"><label> but only if </label></text>'
		mouldConditionName $widget$arg
		mouldConditionParam $widget$arg
		let "index+=1"
	echo '	</hbox>'
	echo '</vbox>
	<label>On '$arg' signal</label>
	<variable>exp'$widget$arg'</variable>
	</expander>'
	done
};export -f mouldSignalList

function mouldSignalActivate()
{
echo '
	<checkbox space-fill="true" space-expand="true">
		<label>If '$2' signal emitted, detected or activated, this widget should </label>
		<default>false</default>
		<variable>vUse'$1$2'</variable>
		<action>echo '$1$2'</action>
		<action>if true enable:vSignalName'$1$2'</action>
		<action>if false disable:vSignalName'$1$2'</action>
		<action>if true enable:vSignalParam'$1$2'</action>
		<action>if false disable:vSignalParam'$1$2'</action>
		<action>if true enable:vCondition'$1$2'</action>
		<action>if false disable:vCondition'$1$2'</action>
		<action>if true enable:vConditionParam'$1$2'</action>
		<action>if false disable:vConditionParam'$1$2'</action>
	</checkbox>
	'
};export -f mouldSignalActivate
function mouldSignalParam()
{

echo '
<comboboxentry auto-refresh="true" file-monitor="true" space-fill="true" space-expand="true" >
	<variable>vSignalParam'$1$2'</variable>
	<default>gActionNothing</default>
	<sensitive>false</sensitive>
	<input file>'$PROGTMP'/SignalParameter</input>
	<output file>'$PROGTMP'/SignalParameter</output>
	<action signal="activate">save:vSignalParam'$1$2'</action>
</comboboxentry>'
gClearButton vSignalParam$1$2
};export -f mouldSignalParam


function mouldSignalName()
{
echo '
    <comboboxtext space-fill="true" space-expand="true">
		<sensitive>false</sensitive>
		<variable>vSignalName'$1'</variable>
		<item>command</item>
		<item>enable</item>
		<item>disable</item>
		<item>show</item>
		<item>hide</item>
		<item>activate</item>
		<item>refresh</item>
		<item>grabfocus</item>
		<item>launch</item>
		<item>presentwindow</item>
		<item>break</item>
		<item>closewindow</item>
		<item>exit</item>
</comboboxtext>
	'
};export -f mouldSignalName
function mouldConditionParam()
{
	
echo '
<comboboxentry auto-refresh="true" file-monitor="true" space-fill="true" space-expand="true" >
	<variable>vConditionParam'$1$2'</variable>
	<default>variable</default>
	<sensitive>false</sensitive>
	<input file>'$PROGTMP'/ConditionParameter</input>
	<output file>'$PROGTMP'/ConditionParameter</output>
	<action signal="activate">save:vConditionParam'$1$2'</action>
</comboboxentry>'
gClearButton vSignalParam$1$2
};export -f mouldConditionParam
function mouldConditionName()
{
echo '
<comboboxtext>
	<sensitive>false</sensitive>
	<variable>vCondition'$1'</variable>
	<item>EarthStillExist</item>
	<item>active_is_true</item>
	<item>active_is_false</item>
	<item>command_is_true</item>
	<item>command_is_false</item>
	<item>file_is_true</item>
	<item>file_is_false</item>
	<item>sensitive_is_true</item>
	<item>sensitive_is_false</item>
	<item>visible_is_true</item>
	<item>visible_is_false</item>
</comboboxtext>
	'
};export -f mouldConditionName
: <<'COMMENTBLOCK'
16<input file stock-column="0">'$PROGLIB'/icon_names.txt</input>

	for arg in "$@"
	do
	
		let "index+=1"
	done
COMMENTBLOCK
function fsignals()
{
gFormCheckboxList Signal "On these signal events XXXXNOT DEVELOP YETXXXX" button-press-event^button-release-event^configure-event^enter-notify-event^leave-notify-event^focus-in-event^focus-out-event^hide^show^realize^key-press-event^key-release-event^map-event^unmap-event
};export -f fsignals

function ftearoff()
{
gFormBool TearOff  "Add tearoff to the menu"
};export -f ftearoff
function fhasframe()
{
gFormBool HasFrame  "A frame is drawn around the entry"
};export -f fhasframe
function ftextedit()
{
gFormTextEdit TextEdit "File pattern to use. Separate by using |"  "*.txt|*.sh|*.tmp|*.xml|*.html|*.c|*.h" 
};export -f ftextedit
function ffontselect()
{
gFormSelectFont Font  "Select a font to use"
};export -f ffontselect
function ffontusefont()
{
gFormBool DisplayFont  "Display the font in button"
};export -f ffontusefont
function ffontusesize()
{
gFormBool DisplaySize  "Display the size in button"
};export -f ffontusesize

function ftabbaseindex()
{
gFormSpinner TabBaseIndex "document-page-setup" "Show this tab page on start (start from page 0)" 0 1
};export -f ftabbaseindex
function ftablabel()
{
gFormTextEdit TabLabel "Tab page title. Separate by using |" "Page 1|Page 2|Page 3"
};export -f ftablabel
function ftabprefix()
{
gFormEntry TabPrefix "gtk-edit" "Prepend this to the tab page title" "["
};export -f ftabprefix
function ftabsuffix()
{
gFormEntry TabSuffix "gtk-edit" "Append this to the tab page title" "]"
};export -f ftabsuffix

function fborderwidth()
{
gFormSpinner BorderWidth "document-page-setup" "Window border width" 5 1
};export -f fborderwidth
function fspacing()
{
gFormSpinner Spacing "document-page-setup" "Box spacing" 0 1
};export -f fspacing
function fheight()
{
gFormSpinner Height "document-page-setup" "Height" 100 1
};export -f fheight
function fwidth()
{
gFormSpinner Width "document-page-setup" "Width" 200 1
};export -f fwidth
function fdefaultitem()
{
gFormSpinner DefaultItem "document-page-setup" "The row to select on initialisation and refresh" 1 1
};export -f fdefaultitem
function fselectevent()
{
gFormSelectEvent EventFile "Events to perform"
};export -f fselectevent
function fselectaction()
{
gFormSelectAction ActionFile "Action to perform"
};export -f fselectaction
function flistitem()
{
gFormSelectInput InputListFile "Use directives from this list"
};export -f flistitem
function CleanUpTreeviewDatafile
{
	local tempfile=$PROGTMP/CleanUpTreeviewtmp
	local workfile=$PROGTMP/CleanUpTreeview
	rm -rf  $tempfile
	cp -f $1 $tempfile
	sed -e "s/"$2"||//g" $tempfile > $workfile; 
	rm -rf  $1
	mv --force $workfile $1;
	echo "" >>  $1
	#sed -e "s/"$3"||//g" $1 > $PROGTMP/CleanUpTreeview; mv -f $PROGTMP/CleanUpTreeview $2; echo "" >>  $2
};export -f CleanUpTreeviewDatafile
function gFormInputMulti()
{
local widgetvar=aaa_checkbox.input
local tmpfile=$PROGTMP/$widgetvar
local workfile=$PROJECTDIR/src/res/$widgetvar
echo '
<hbox>
	<hbox space-expand="true" space-fill="true">
		<vbox>
		<tree icon-name="application-x-executable">
			<variable export="true">vInputList</variable>
			<label>Input Directive</label>
			<height>150</height>
			<input file>'$workfile'</input>
			<output file>'$workfile'</output>
		</tree>
		<hbox homogeneous="true">
		<button space-fill="true" homogeneous="true">
			<variable>btnRefreshInputList</variable>
			<label>Refresh</label>
			<sensitive>true</sensitive>
			<input file stock="gtk-refresh"></input>
			<action>refresh:vInputList</action>
		</button>
		<button space-fill="true" homogeneous="true">
			<variable>btnDeleteInputItem</variable>
			<label>Delete</label>
			<sensitive>true</sensitive>
			<input file stock="gtk-remove"></input>
			<action>removeselected:vInputList</action>
			<action>save:vInputList</action>
			<action>CleanUpTreeviewDatafile '$workfile' application-x-executable</action>
			<action>refresh:vInputList</action>
		</button>
	</hbox>
		</vbox>
	</hbox>
	<vbox space-expand="true" space-fill="true" >
		
<tree space-expand="true" exported-column="2" space-fill="true" auto-refresh="true" file-monitor="true" column-visible="true|true|true" icon-name="text-x-generic-template">
	<variable>vCollectionInput</variable>
	<label>Type|Description|Directive</label>
	<height>150</height>
	<input file icon-column="0">'$PROJECTDIR'/src/lib/datasource.data</input>
	<action signal="row-activated">echo $vCollectionInput >> '$workfile'</action>
	<action>refresh:vInputList</action>
</tree>
			<button space-expand="true" theme-icon-size="16">
				<variable>btnDataSourceManager</variable>
				<label>Data Source Manager</label>
				<sensitive>true</sensitive>
				<input file icon="applications-development"></input>
				<action>XMLRunDialog DataSourceManager</action>
			</button>

		</vbox>
</hbox>'
: <<'COMMENTBLOCK'

COMMENTBLOCK
};export -f gFormInputMulti
function fdefaultrange()
{
gFormSpinner DefaultRange "document-page-setup" "Default starting range" 50.0000 0.1
};export -f fdefaultrange
function frangestep()
{
gFormSpinner RangeStep "document-page-setup" "Range increment step" 1.0000 0.0001
};export -f frangestep
function frangemax()
{
gFormSpinner RangeMax "document-page-setup" "Maximum range achieveable" 100.0000 0.1
};export -f frangemax
function frangemin()
{
gFormSpinner RangeMin "document-page-setup" "Minimum range allowed" 0 0.1
};export -f frangemin
function fusealpha()
{
gFormBool Alpha "Enable transparency"
};export -f fusealpha
function fselectcolor()
{
gFormSelectColor Color "Select a color"
};export -f fselectcolor
function ffstype()
{
gFormComboSelect FSType "Fileselect function action type" "file^newfile^folder^newfolder"
};export -f ffstype

function ffsfolder()
{
gFormEntry FSFolder "gtk-edit" "Directory to start browsing" "\$HOME"
};export -f ffsfolder
function ffstitle()
{
gFormEntry FSTitle "gtk-edit" "Use this as the the dialog title" "...or you can use the standard"
};export -f ffstitle
function ffsfilter()
{
gFormTextEdit FSFilter "File pattern to use. Separate by using |"  "*.txt|*.sh|*.tmp|*.xml|*.html|*.c|*.h"
};export -f ffsfilter

function ffsfiltermime()
{
gFormTextEdit FSFilterMime "Mime pattern to use. Separate by using |"  "text/html|text/plain|text/richtext|text/rtf|text/xml"
};export -f ffsfiltermime
function fhscrollbar()
{
gFormComboSelect HScrollBar "Show horizontal scrollbar for the area"  "Always^Automatic^Never"
};export -f fhscrollbar
function fvscrollbar()
{
gFormComboSelect VScrollBar "Show vertical scrollbar for the area"  "Always^Automatic^Never"
};export -f fvscrollbar
function fshadowtype()
{
gFormComboSelect ShadowType "Viewport shadow type" "None^Bevelled In^Bevelled Out^Sunken 3D^Raised 3D"
};export -f fshadowtype

function finputfile()
{
gFormFile InputFile "Use this file as data input"
};export -f finputfile
function foutputfile()
{
gFormFile OutputFile "Use this file as data output storage"
};export -f foutputfile
function finput()
{
gFormEntry InputCommand gtk-convert "Use this command as data input" "echo \"true\""
};export -f finput
function flabel()
{
gFormEntry Label gtk-bold "This widget have a label" "Yay"
};export -f flabel
function ftitle()
{
gFormEntry Label gtk-bold "Title for the window" $PROGNAME
};export -f ftitle

function fspaceexpand()
{
gFormBool SpaceExpand "Will expand if the container space expand"
};export -f fspaceexpand
function ftimervisible()
{
gFormBool TimerVisible "Make this timer visible"
};export -f ftimervisible
function finterval()
{
gFormEntry Interval gtk-edit "Timer frequency" "100"
};export -f finterval
function fmiliseconds()
{
gFormBool Miliseconds "This timer use precision"
};export -f fmiliseconds
function fscrollable()
{
gFormBool Scrollable "This area have scrolled window capability"
};export -f fscrollable
function ffilemonitor()
{
gFormBool FileMonitor "Monitor the input file for changes"
};export -f ffilemonitor
function fautorefresh()
{
gFormBool AutoRefresh "Refresh the widget data if input file change"
};export -f fautorefresh
function fhomogeneous()
{
gFormBool Homogeneous "Child widgets should all be the same size."
};export -f fhomogeneous
function fblockfxsignal()
{
gFormBool BlockSignal "Block signal emissions from functions "
};export -f fblockfxsignal
function fspacefill()
{
gFormBool SpaceFill "Will fill the empty space in container"
};export -f fspacefill
function fdimensionrequest()
{
#	'"$(fdimensionrequest)"'
echo '
	<hbox homogenous="true" space-fill="true" space-expand="false">
		<checkbox space-fill="true" space-expand="true">
			<label>Request Width</label>
			<default>false</default>
			<variable>vUseWidthRequest</variable>
			<action>if true enable:vWidthRequest</action>
			<action>if false disable:vWidthRequest</action>
		</checkbox>
		<spinbutton width-request="100" range-value="" xalign="1" primary-icon-stock="gtk-fullscreen" range-step="1">
			<sensitive>false</sensitive>
			<variable>vWidthRequest</variable>
			<action signal="primary-icon-press">refresh:vWidthRequest</action>
		</spinbutton>
	</hbox>
	<hbox>
		<checkbox space-fill="true" space-expand="true">
			<label>Request Height</label>
			<default>false</default>
			<variable>vUseHeightRequest</variable>
			<action>if true enable:vHeightRequest</action>
			<action>if false disable:vHeightRequest</action>
		</checkbox>
		<spinbutton width-request="100" range-value="" xalign="1" primary-icon-stock="gtk-fullscreen" range-step="1">
			<sensitive>false</sensitive>
			<variable>vHeightRequest</variable>
			<action signal="primary-icon-press">refresh:vHeightRequest</action>
		</spinbutton>
	</hbox>
'
};export -f fdimensionrequest

function fsensitive()
{
#   '"$(fsensitive skel_)"'
gFormBool Sensitive "On creation widget is enabled"
};export -f fsensitive

function fdefaultbool()
{
#   '"$(fsensitive skel_)"'
gFormBool DefaultBool "Default boolean value"
};export -f fdefaultbool

function fpositionmark()
{
gFormEntry PositionMark gtk-edit "Position mark" "Still under construction"
};export -f fpositionmark

function fdefaulttext()
{
gFormEntry DefaultText gtk-edit "Default text to display" "Text"
};export -f fdefaulttext
function fdefaultdouble()
{
gFormSpinner DefaultDouble battery-low "Default initial value to start" "0.10" 0.10
};export -f fdefaultdouble

function fvariable()
{
#	'"$(fvariable vWidget)"'
local usevariable=`gInitVar "$vGUID" "vUseVariable" 'true'`
local varname=`gInitVar "$vGUID" "vVariable" $widget$RANDOM`
echo '
<hbox>
	<checkbox space-fill="true" space-expand="true">
		<label>Variable name</label>
		<default>'$usevariable'</default>
		<variable>vUseVariable</variable>
		<action>if true enable:vVariable</action>
		<action>if false disable:vVariable</action>
		<action>if true enable:vUseVariableExport</action>
		<action>if false disable:vUseVariableExport</action>
	</checkbox>
	<entry primary-icon-stock="gtk-dialog-authentication" primary-icon-activatable="false">
		<default>'$varname'</default>
		<variable>vVariable</variable>
	</entry>
</hbox>'
gFormBool VariableExport "Export this variable"
};export -f fvariable

function fselectpixmap()
{
gFormSelectIcon Pixmap "Use this picture"
};export -f fselectpixmap
function fselectappicon()
{
gFormSelectIcon AppIcon "Use this icon as window icon"
};export -f fselectappicon
function ftreedefaulticon()
{
gFormSelectIcon TreeDefaultIcon "Use icon"
};export -f ftreedefaulticon
function fselecticon()
{
gFormSelectIcon Icon "Use icon"
};export -f fselecticon
function gFormSelectIcon()
{
#   '"$(fselectstockicon)"'
cp --force $PROGLIB/theme_actions.csv  $PROGTMP/vContext
local usevariable=`gInitVar "$vGUID" "vUse$1" 'false'`
local value=`gInitVar "$vGUID" "v$1" "None selected"`
local usetheme=`gInitVar "$vGUID" "vUse$1"Theme "false"`
local usestock=`gInitVar "$vGUID" "vUse$1"Stock "false"`
local usecustom=`gInitVar "$vGUID" "vUse$1"Custom "false"`
if [ "$usevariable" == "true" ]
then
	local sensitive="true"
else
	local sensitive="false"
fi
if [ "$usetheme" == "true" ]
then
	local themesensitive="true"
	local stocksensitive="false"
	local customsensitive="false"
else
	local themesensitive="false"
fi
if [ "$usestock" == "true" ]
then
	local stocksensitive="true"
	local themesensitive="false"
	local customsensitive="false"
else
	local stocksensitive="false"
fi
if [ "$usecustom" == "true" ]
then
	local customsensitive="true"
	local stocksensitive="false"
	local themesensitive="false"
else
	local customsensitive="false"
fi
echo -n $value > $PROGTMP/v$1
 echo '<vbox>
<hbox>
	<checkbox space-fill="true" space-expand="true">
		<label>'$2'</label>
		<default>'$usevariable'</default>
		<variable>vUse'$1'</variable>
		<action>if true enable:vUse'$1'Blank</action>
		<action>if false disable:vUse'$1'Blank</action>
		<action>if true enable:vUse'$1'Theme</action>
		<action>if false disable:vUse'$1'Theme</action>
		<action>if true enable:vUse'$1'Stock</action>
		<action>if false disable:vUse'$1'Stock</action>
		<action>if true enable:vUse'$1'Custom</action>
		<action>if false disable:vUse'$1'Custom</action>
		<action>if true enable:v'$1'</action>
		<action>if false disable:v'$1'</action>
		<action>if true enable:v'$1'Theme</action>
		<action>if false disable:v'$1'Theme</action>
		<action>if false disable:v'$1'Stock</action>
		<action>if false disable:v'$1'Custom</action>
		<action>if true enable:vUse'$1'Pos</action>
		<action>if false disable:vUse'$1'Pos</action>
		<action>refresh:v'$1'</action>
	</checkbox>
	<entry space-fill="true" space-expand="true" auto-refresh="true" file-monitor="true" fs-action="file" fs-folder="/usr/share/pixmaps" fs-title="Select the icon file" fs-filters="*.svg|*.png|*.gif|*.jpg|*.bmp|*.xpm">
		<variable>v'$1'</variable>
		<sensitive>'$sensitive'</sensitive>
		<output file>'$PROGTMP'/v'$1'</output>
		<input file>'$PROGTMP'/v'$1'</input>
		<action signal="activate">save:v'$1'</action>
		<action signal="file-changed">refresh:v'$1'</action>
	</entry>
</hbox>
	<hbox homogeneous="true">
		<radiobutton space-fill="true" space-expand="true">
			<label>Use theme icon</label>
			<default>'$themesensitive'</default>
			<variable>vUse'$1'Theme</variable>
			<sensitive>'$sensitive'</sensitive>
			<action>if true enable:v'$1'Theme</action>
			<action>if false disable:v'$1'Theme</action>
			<action>if true enable:vUse'$1'ThemeSize</action>
			<action>if false disable:vUse'$1'ThemeSize</action>
		</radiobutton>
		<radiobutton space-fill="true" space-expand="true">
			<label>Use stock icon</label>
			<default>'$stocksensitive'</default>
			<variable>vUse'$1'Stock</variable>
			<sensitive>'$sensitive'</sensitive>
			<action>if true enable:v'$1'Stock</action>
			<action>if false disable:v'$1'Stock</action>
			<action>if true enable:vUse'$1'StockSize</action>
			<action>if false disable:vUse'$1'StockSize</action>
		</radiobutton>
		<radiobutton space-fill="true" space-expand="true">
			<label>Use custom icon</label>
			<default>'$customsensitive'</default>
			<variable>vUse'$1'Custom</variable>
			<sensitive>'$sensitive'</sensitive>
			<action>if true enable:v'$1'Custom</action>
			<action>if false disable:v'$1'Custom</action>
			<action>refresh:v'$1'</action>
		</radiobutton>
	</hbox>
	<hbox homogeneous="true">
		<button space-fill="true" space-expand="false">
			<sensitive>'$themesensitive'</sensitive>
			<label>Theme</label>
			<variable>v'$1'Theme</variable>
			<input file icon="document-open"></input>
			<action>echo fileselect:v'$1'</action>
			<action>XMLRunDialog IconChooseTheme</action>
		</button>
		<button space-fill="true" space-expand="false">
			<sensitive>'$stocksensitive'</sensitive>
			<label>Stock</label>
			<variable>v'$1'Stock</variable>
			<input file icon="document-open"></input>
			<action>echo fileselect:v'$1'</action>
			<action>XMLRunDialog IconChooseStock</action>
		</button>
		<button space-fill="true" space-expand="false">
			<sensitive>'$customsensitive'</sensitive>
			<label>Custom</label>
			<variable>v'$1'Custom</variable>
			<input file icon="document-open"></input>
			<action>echo fileselect:v'$1'</action>
			<action>fileselect:v'$1'</action>
		</button>
	</hbox>
<hbox>'
ficonpos
	echo '<vbox>'
		ficonstocksize
		ficonthemesize
	echo '</vbox>'
: <<'COMMENTBLOCK'
'
COMMENTBLOCK

echo '</hbox>
</vbox>'
};export -f gFormSelectIcon
function ficonstocksize()
{
gFormComboSelect IconStockSize "Stock icon size" "None^Menu^Small Toolbar^Large Toolbar^Button^Drag n drop^Dialog"
};export -f ficonstocksize

function ficonsize()
{
gFormSpinner IconCustomSize "preferences-desktop-theme" "Size for the icon ?" 16 1
};export -f ficonsize
function ficonthemesize()
{
gFormSpinner IconThemeSize "preferences-desktop-theme" "Theme icon size" 20 1
};export -f ficonthemesize
function ftabposition()
{
gFormPosition TabPosition "Notebook tabs position"
};export -f ftabposition
function ficonpos()
{
gFormPosition IconPosition "Icon position"
};export -f ficonpos







